Skip to content

Dev#13

Merged
Warhammer4000 merged 11 commits into
mainfrom
dev
Jun 11, 2026
Merged

Dev#13
Warhammer4000 merged 11 commits into
mainfrom
dev

Conversation

@Warhammer4000

Copy link
Copy Markdown
Contributor

No description provided.

Refactor audit log handling and improve hardware/software collectors across platforms.

- Replace ad-hoc periodic audit ticker with a logging integration started/stopped by the CLI; remove the program-level audit goroutine and startup of AuditLogService.
- AuditLogService: introduce HTTP helpers (newRequest, doRequest), use context-aware SendBatchLogsWithContext, tighten types to map[string]any, improved logging, and smaller error messages; remove legacy generators/tests and deprecated batch helpers.
- RAM parsing: massively refactor dmidecode parsing with helper functions (fieldValue, applyDmidecodeField), better fallback logic (readTotalMemKB, ramTypeFromEDAC, lshw helpers, manufacturerFromDMI) and cleaner lshw parsing.
- Software collectors: set FirstSeenAt when available (mac: LastModified from system profiler, rpm: INSTALLTIME, windows: InstallDate, browser extensions: file mod time).
- Minor fixes: make systemd unit write exempt from gosec, normalize mac GPU CurrentStatus to "unknown".

These changes centralize HTTP request handling for audit logs, improve metadata accuracy for RAM and installed software, and simplify lifecycle management for the logging/audit flow.
Make audit-log checkpoint handling tolerant of different numeric types by adding CheckpointInt64/CheckpointFloat64 and updating platform collectors and parsers to use them (prevents panics after JSON round-trip). Parse syslog/mac timestamps in local time. Harden config handling: add token mutex with Get/Set accessors, atomic SaveAtomic refactor to use unique temp files and platform-specific hardening (Unix chmod / Windows DACL), reconcile persisted version with runtime, and add concurrency tests. Improve lockfile and startup semantics: use a version-independent lock name, close-before-remove, platform-specific non-destructive IsProcessRunning implementations, and make service startup synchronous with proper lock release on failure. Misc: enhanced auth token refresh logic (skewed preemptive refresh), assorted tests, and README/documentation updates.
Add ed25519-based release signing and verification plus safety fixes for task execution and agent info collection.

- Release/CI: run scripts/sign in release workflow and upload SHA256SUMS; add `sign` target to Makefile and integrate it into `make release`. Requires SENTINELGO_SIGNING_KEY env var.
- Updater: selectAssetWithChecksum now locates .sig and SHA256SUMS; downloadAndVerify verifies SHA256 and ed25519 signature (fail-closed on missing/invalid .sig); added embedded PublicKey and signature verification helpers and tests.
- Tools: add scripts/sign (create .sig and SHA256SUMS) and scripts/keygen (generate keypair and outputs for CI/pubkey).
- Tasks: prevent unsafe re-execution by marking tasks 'executing' before running, add ResetInterruptedTasks to mark stuck tasks as failed, wire ResetInterruptedTasks into polling startup flow, and add unit tests for store behavior.
- Executor: refactor to executeTask to reduce complexity, ensure marking as executing before run and report results.
- Scheduler/config: reduce agent-info update interval to 5m and add a timeout around osinfo.Collect to avoid hangs; add scheduler logging for intervals.

These changes improve update authenticity (signed releases) and runtime robustness (task state safety and hung-collection protection).
Add cross-platform USB mass storage state collection and related refactors/tests.

- macOS: add collectUSBMassStorage which reads MDM plist via plutil or checks kextstat; add JSON parser and tests. Introduce avCrowdStrikeFalcon constant and small struct formatting changes.
- Linux: detect usb_storage via /sys/module or modprobe.d blacklists (scan *.conf); add helpers usbStorageStateFromModprobeDir and usbStorageStateFromConfFile with tests. Refactor SELinux and SecureBoot parsing into standalone helpers and use filepath for efivars lookup. Extract AV service probing into probeAVService.
- Windows: add collectUSBMassStorage that queries USBSTOR Start DWORD and maps it to enabled/disabled with tests for mapping.
- Shared: add USBMassStorageEnabled field to SecurityInfo JSON type.
- CI: ensure shell scripts are executable in release workflow.

These changes enable reporting of whether removable USB mass storage is permitted, improve parsing/testability of several platform checks, and make release scripts executable.
@Warhammer4000 Warhammer4000 enabled auto-merge (rebase) June 11, 2026 16:40
for _, e := range entries {
if strings.HasPrefix(e.Name(), "SecureBoot-") {
data, rerr := os.ReadFile("/sys/firmware/efi/efivars/" + e.Name())
data, rerr := os.ReadFile(filepath.Join(efivarsDir, e.Name()))
// replaced binary has a completely different hash, so without this launchd
// cannot restart the updated binary (Gatekeeper rejects it silently).
func recodesignForGatekeeper(selfPath string) {
_ = exec.Command("xattr", "-d", "com.apple.quarantine", selfPath).Run()
// cannot restart the updated binary (Gatekeeper rejects it silently).
func recodesignForGatekeeper(selfPath string) {
_ = exec.Command("xattr", "-d", "com.apple.quarantine", selfPath).Run()
_ = exec.Command("codesign", "--force", "--sign", "-", selfPath).Run()
func recodesignForGatekeeper(selfPath string) {
_ = exec.Command("xattr", "-d", "com.apple.quarantine", selfPath).Run()
_ = exec.Command("codesign", "--force", "--sign", "-", selfPath).Run()
_ = exec.Command("spctl", "--add", selfPath).Run()
auto-merge was automatically disabled June 11, 2026 17:33

Rebase failed

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
9 Security Hotspots
27.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Warhammer4000 Warhammer4000 enabled auto-merge June 11, 2026 17:36
@Warhammer4000 Warhammer4000 merged commit a843e33 into main Jun 11, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants